//
//  NetworkResponse.swift
//

import UIKit

struct Response<T: Codable>: Codable {
    let errorCode: Int
    let errorMessage: String
    let result: T
    
    var success: Bool {
        return errorCode == 0
    }
    
    var appError: AppError {
        return AppError(code: errorCode, errorMessage: errorMessage)
    }
}

struct AudioResponse<T: Codable>: Codable {
    let errcode: String
    let errmsg: String
    let data: T
    
    var success: Bool {
        return errcode == "0"
    }
    
    var appError: AppError {
        return AppError(code: Int(errcode) ?? 0000, errorMessage: errmsg)
    }
    
    enum CodingKeys: String, CodingKey {
        case errcode
        case errmsg
        case data
    }
}
